import os
from time import sleep
import uiautomation
import pyautogui

from config.config import DATA_PATH
from tools.sjqd_way import read_data_from_excel


class zhuyuanhushizhan():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()
        #患者列表
        zidingyi = his.CustomControl(AutomationId='cwListCtrl',ClassName='ChuangWeiLiuLan')
        bingqu = his.ComboBoxControl(ClassName='ComboBox',foundIndex=2)
        shurukuang = his.EditControl(AutomationId='hzxx_txt',ClassName='TextBox')
        chaxunanniu = his.ButtonControl(AutomationId='btnQuery',ClassName='Button')
        yizhuzhixing = his.ButtonControl(AutomationId='btn_yzzx',ClassName='Button')
        gongzuodan =  zidingyi.ButtonControl(ClassName='Button',foundIndex=6)
        linyaodan =  zidingyi.ButtonControl(ClassName='Button',foundIndex=7)
        zidongjifei =  zidingyi.ButtonControl(ClassName='Button',foundIndex=8)
        sancedan =  zidingyi.ButtonControl(ClassName='Button',foundIndex=9)
        dianzibingliliulan = zidingyi.ButtonControl(ClassName='Button',foundIndex=10)
        yiriqingdanfeiyongdaying =  zidingyi.ButtonControl(ClassName='Button',Name='一日清单费用打印')

        #第一个床位定位
        chuangwei1 = his.ListControl(AutomationId='cwlist_lb',ClassName='ListBox').ListItemControl(ClassName='ListBoxItem',Name='Ksy.ChssClient.Access.Model.ZD_CWLB')
        #右键菜单定位
        caidan = his.MenuControl(ClassName='ContextMenu')
        anpaichuangwei = caidan.MenuItemControl(ClassName='MenuItem',foundIndex=1)
        #安排床位窗口
        anpaichuangweichuangkou = his.WindowControl(AutomationId='apcwWin',ClassName='Window')
        shujuwangge = anpaichuangweichuangkou.DataGridControl(AutomationId='hzlist_dg',ClassName='DataGrid')
        zhuzhiyisheng = anpaichuangweichuangkou.EditControl(AutomationId='PART_TextBox',ClassName='TextBox',foundIndex=1)
        shangjiyisheng =anpaichuangweichuangkou.EditControl(AutomationId='PART_TextBox',ClassName='TextBox',foundIndex=2)
        kezhuren =anpaichuangweichuangkou.EditControl(AutomationId='PART_TextBox',ClassName='TextBox',foundIndex=3)
        zerenhushizhang = anpaichuangweichuangkou.EditControl(AutomationId='PART_TextBox',ClassName='TextBox',foundIndex=4)
        quedinganiu = anpaichuangweichuangkou.ButtonControl(AutomationId='confirm_btn',ClassName='Button',Name='确定')
        # 安排床位
        def ckick_apcw(self,zzys,sjys,kzr,zrhs):
                self.chuangwei1.RightClick()
                self.anpaichuangwei.Click()
                self.shujuwangge.GetLastChildControl().Click()
                self.zhuzhiyisheng.Click()
                self.zhuzhiyisheng.SendKeys(zzys)
                sleep(1)
                pyautogui.press('enter')
                self.shangjiyisheng.Click()
                self.shangjiyisheng.SendKeys(sjys)
                sleep(1)
                pyautogui.press('enter')
                self.kezhuren.Click()
                self.kezhuren.SendKeys(kzr)
                sleep(1)
                pyautogui.press('enter')
                self.zerenhushizhang.Click()
                self.zerenhushizhang.SendKeys(zrhs)
                sleep(1)
                pyautogui.press('enter')
                self.quedinganiu.Click()



        #选择病区
        def choose_bq(self,bq):
                self.bingqu.SendKeys(bq)

        #输入住院患者信息
        def input_hzxx(self,name):
                self.shurukuang.SendKeys(name)

        #点击查询按钮
        def click_cx_btn(self):
                self.chaxunanniu.Click()

        #点击医嘱执行单
        def click_yzzx_btn(self):
                self.yizhuzhixing.Click()
        #点击工作单
        def click_gzd_btn(self):
                self.gongzuodan.Click()
        #点击领药单
        def click_lyd_btn(self):
                self.linyaodan.Click()

        #点击自动计费
        def click_zdjf_btn(self):
                self.zidongjifei.Click()

        #点击三测单
        def click_scd_btn(self):
                self.sancedan.Click()
        #点击电子病历浏览
        def click_dzblln_btn(self):
                self.dianzibingliliulan.Click()
        #点击一日清单费用打印
        def click_yrqdfydy_btn(self):
                self.yiriqingdanfeiyongdaying.Click()



